/*------------------------------------------------------------------------------
 * MediaTek Inc. (C) 2019. All rights reserved.
 *
 * Copyright Statement:
 *
 * This software/firmware and related documentation ("MediaTek Software") are
 * protected under relevant copyright laws. The information contained herein is
 * confidential and proprietary to MediaTek Inc. and/or its licensors. Without
 * the prior written permission of MediaTek inc. and/or its licensors, any
 * reproduction, modification, use or disclosure of MediaTek Software, and
 * information contained herein, in whole or in part, shall be strictly
 * prohibited.
 *
 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
 * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
 * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
 * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
 * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
 * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
 * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
 * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
 * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
 * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
 * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
 * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
 * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
 * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
 *
 * The following software/firmware and/or related documentation ("MediaTek
 * Software") have been modified by MediaTek Inc. All revisions are subject to
 * any receiver's applicable license agreements with MediaTek Inc.
 *----------------------------------------------------------------------------*/
//-------------------------------------------------------------------------------------------------
// Use GetAttr/SetAttr only
//-------------------------------------------------------------------------------------------------

#ifndef _HR_TV_VOC_H_
#define _HR_TV_VOC_H_
#include "mi_common.h"
#include "hr_common.h"

#ifdef __cplusplus
extern "C" {
#endif

//-------------------------------------------------------------------------------------------------
//  Enum
//-------------------------------------------------------------------------------------------------
///VOC Preprocess Output type
typedef enum
{
    E_MI_VOC_PREPROCESS_OUTPUT_NONE = -1,
    E_MI_VOC_PREPROCESS_OUTPUT_QCOM = 0,        ///< Set Output type as QCOM
    E_MI_VOC_PREPROCESS_OUTPUT_QSR,             ///< Set Output type as QSR
    E_MI_VOC_PREPROCESS_OUTPUT_UFB,             ///< Set Output type as UFB
    E_MI_VOC_PREPROCESS_OUTPUT_TOTAL,
}MI_VOC_PreprocessOutputType_e;

///VOC Notify type
typedef enum
{
    E_MI_VOC_TO_WORKING,                        ///< to working
    E_MI_VOC_TO_SMARTSPEAKER,                   ///< to smartspeaker
    E_MI_VOC_NOTIFY_TYPE_MAX,
}MI_VOC_NotifyType_e;

///VOC State type
typedef enum
{
    E_MI_VOC_WORKING = 0,                       ///< working state
    E_MI_VOC_SMART_SPEAKER,                     ///< smart speaker
    E_MI_VOC_STATE_MAX,
}MI_VOC_STATE_e;

///VOC PCM format type for input stream
typedef enum
{
    E_MI_VOC_PCM_FORMAT_INVALID = -1,
    E_MI_VOC_PCM_FORMAT_S16_LE   = 0,           ///< 16-bit signed
    E_MI_VOC_PCM_FORMAT_S32_LE,                 ///< 32-bit signed
    E_MI_VOC_PCM_FORMAT_S8,                     ///< 8-bit signed
    E_MI_VOC_PCM_FORMAT_S24_LE,                 ///< 24-bits in 4-bytes
    E_MI_VOC_PCM_FORMAT_S24_3LE,                ///< 24-bits in 3-bytes
    E_MI_VOC_PCM_FORMAT_MAX,
} MI_VOC_PcmFormat_e;

///VOC Attribute type
typedef enum
{
    E_MI_VOC_ATTR_TYPE_ENABLE_MIC = 0,          ///< (Set/Get)ENABLE MIC
    E_MI_VOC_ATTR_TYPE_ENABLE_WAKEUP,           ///< (Set/Get)ENABLE WAKEUP
    E_MI_VOC_ATTR_TYPE_ENABLE_SEAMLESS,         ///< (Set/Get)ENABLE SEAMLESS
    E_MI_VOC_ATTR_TYPE_NOTIFY_POWER_STATE,      ///< (Set/Get)POWER STATE, unsupport, remove
    E_MI_VOC_ATTR_TYPE_CURRECT_STATE,           ///< (Get/Set) CURRECT STATE
    E_MI_VOC_ATTR_TYPE_APP_TIMEOUT,             ///< (Set/Get) release lock, unsupport, remove
    E_MI_VOC_ATTR_TYPE_SMART_SPEAKER,           ///< (Set/Get) Smart Speaker
    E_MI_VOC_ATTR_TYPE_WAKEUP_WORD_EVENT,       ///< (Set) WAKEUP_WORD_EVENT
    E_MI_VOC_ATTR_TYPE_OUTPUT_TYPE,             ///< (Set) Output type
    E_MI_VOC_ATTR_TYPE_PERIOD_SIZE,             ///< (Get) Period Size
    E_MI_VOC_ATTR_TYPE_PERIOD_COUNT,            ///< (Get) Period Count
    E_MI_VOC_ATTR_TYPE_MAX,
}MI_VOC_AttrType_e;

//-------------------------------------------------------------------------------------------------
//  Structure
//-------------------------------------------------------------------------------------------------

/* Configuration for a Preprocess output */
/* ChannelNo   [IN] : which channel ,0/1/2/3
// OutputType  [IN] : expected output type*/
typedef struct MI_VOC_PreprocessOutputType_s
{
    MI_U8 u8ChannelNo;
    MI_VOC_PreprocessOutputType_e eOutputType;
} MI_VOC_PreprocessOutputType_t;

/* Configuration for a key word founded between smple index */
/* BeginSampleIndex [IN] : Begin Index
// EndSampleIndex   [IN] : End Index*/
typedef struct MI_VOC_PreprocessWakeupWordEvent_s
{
    MI_U64 u64BeginSampleIndex;
    MI_U64 u64EndSampleIndex;
} MI_VOC_PreprocessWakeupWordEvent_t;

/* Configuration for a stream */
// OutputChannelNumber [IN]: Channel number for output
// Sampling rate [IN]: Sampling rate, 48000(48KHz), 44100(44.1KHz), 32000(32KHz),....
// PcmFormat     [IN]: PCM data format
// bDynamicChanneNumber [IN]: true: set channel number by user false: set from ini file
// u8OutputRefChannelNumber [IN]: set ref channel number if bDynamicChanneNumber is true*/
typedef struct MI_VOC_PcmConfigs_s
{
    MI_U8  u8OutputChannelNumber;
    MI_U32 u32SampleRate;
    MI_VOC_PcmFormat_e ePcmFormat;
    MI_BOOL bDynamicChanneNumber;
    MI_U8  u8OutputRefChannelNumber;
}MI_VOC_PcmConfigs_t;

/// VOC init function parameters
typedef struct MI_VOC_InitParams_s
{
    MI_U8 u8Reserved;
} MI_VOC_InitParams_t;

/// VOC Open function parameters
typedef struct MI_VOC_OpenParams_s
{
    MI_VOC_PcmConfigs_t stPcmConfigs;           ///< [IN]: PCM Configs for input stream
    MI_BOOL bDoPreprocess;                      ///< [IN]: output data after pre-process or not
}MI_VOC_OpenParams_t;

/// VOC Read function parameters
typedef struct MI_VOC_ReadParams_s
{
    MI_U32 u32FrameSize; /// [IN]: Request Size of VOC data
}MI_VOC_ReadParams_t;

///VOC Read function parameters for output
typedef struct MI_VOC_ReadOutputParams_s
{
    MI_U32 u32PcmDataSize;  /// [OUT]: Size of Pcm data
    void   *pPcmBuf;        /// [OUT]: Buffer of Pcm data
}MI_VOC_ReadOutputParams_t;

/// VOC GetAttr function parameters
typedef struct MI_VOC_GetAttrParams_s
{
    MI_U8 u8Reserved;
} MI_VOC_GetAttrParams_t;

/// VOC Query function parameters
typedef struct MI_VOC_QueryHandleParams_s
{
    MI_U8 u8Reserved;
}MI_VOC_QueryHandleParams_t;

//-------------------------------------------------------------------------------------------------
//  Global Functions
//-------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// @brief VOC init.
/// @param[in] pstInitParams.
/// @return MI_OK: Process success.
/// @return MI_HAS_INITED: Voc module is inited
/// @return MI_ERR_FAILED: Process fail.
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_Init(const MI_VOC_InitParams_t *pstInitParams);

//------------------------------------------------------------------------------
/// @brief VOC Deinit.
/// @return MI_OK: Process success.
/// @return MI_ERR_FAILED: Process fail.
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_DeInit(void);

//------------------------------------------------------------------------------
/// @brief VOC open.
/// @param[in] pstOpenParams
/// @param[out] phVoc. The handler of VOC
/// @return MI_OK: Process success.
/// @return MI_ERR_FAILED: Process fail.
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_Open(const MI_VOC_OpenParams_t *pstOpenParams, MI_HANDLE *phVoc);

//------------------------------------------------------------------------------
/// @brief VOC close.
/// @param[in] hVoc. The handler of VOC.
/// @return MI_OK: Process success.
/// @return MI_ERR_FAILED: Process fail.
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_Close(MI_HANDLE hVoc);

//------------------------------------------------------------------------------
/// @brief VOC read.
/// @param[in] hVoc. The handler of VOC
/// @param[in] pInputParams
/// @param[out] pstOutputParams: Output parameter for reading.
/// @return MI_OK: Process success.
/// @return MI_ERR_FAILED: Process fail.
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_Read(MI_HANDLE hVoc, MI_VOC_ReadParams_t *pstReadParams, MI_VOC_ReadOutputParams_t *pstReadOutputParams);

//------------------------------------------------------------------------------
/// @brief Set VOC Attribute.
/// @param[in] hVoc. The handler of VOC
/// @param[in] eAttrType
/// @param[in] pAttrParams,
/// @return MI_OK: Process success.
/// @return MI_ERR_FAILED: Process failed
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_SetAttr(MI_HANDLE hVoc, MI_VOC_AttrType_e eAttrType, const void *pAttrParams);

//------------------------------------------------------------------------------
/// @brief Get VOC attribute.
/// @param[in] hVoc. Voc handle to process.
/// @param[in] eAttrType. Type of attribution.
/// @param[in] *pInputParams. Input paramters.
/// @param[out] *pOutputParams. Output paramters.
/// @return MI_OK: Process success.
/// @return MI_ERR_FAILED: Process fail.
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_GetAttr(MI_HANDLE hVoc, MI_VOC_AttrType_e eAttrType, const void *pInputParams, void *pOutputParams);

//------------------------------------------------------------------------------
/// @brief get VOC handle with capture device name.
/// @param[in] pstQueryParams: Paramter for querying VOC handle.
/// @param[out] phVoc: A handle pointer to retrieve an instance of a created VOC.
/// @return MI_OK: Process success.
/// @return MI_ERR_FAILED: Process fail.
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_GetHandle(const MI_VOC_QueryHandleParams_t *pstQueryParams, MI_HANDLE *phVoc);

//------------------------------------------------------------------------------
/// @brief set debug level.
/// @param[in] u32DebugLevel.
/// @return MI_OK: Process success.
/// @return MI_ERR_FAILED: Process fail.
//------------------------------------------------------------------------------
MI_RESULT MI_VOC_SetDebugLevel(MI_DBG_LEVEL u32DebugLevel);

#ifdef __cplusplus
}
#endif

#endif // _HR_TV_VOC_H_